/*
 * aurora - Communications with Magnetek Aurora Inverter
 *
 * Copyright (C) 2006-2010 Curtis J. Blank curt@curtronics.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program may be used and hosted free of charge by anyone for
 * personal purposes as long as this and all included copyright
 * notice(s) remain intact.
 *
 * Obtain permission before selling the code for this program or
 * hosting this software on a commercial website, excluding if it is
 * solely hosted for distribution, that is allowable . In all cases
 * copyright must remain intact.
 *
 * This work based on Magnetek's 'Aurora PV Inverter - Communications
 * Protocol -' document, Rel. 1.8 09/05/2005
 * Staring with v1.5-0 this work based on Power One's 'Aurora Inverter
 * Series - Communication Protocol -' document, Rel. 4.6 25/02/09
 *
 * Special thanks to Tron Melzl at Magnetek for all his help including,
 * but not limited to, supplying the Communications Protocol document
 *
 */

#define	VersionNH	"1.6.7"

/* # 50 State Request */

#define	opGetState	50
#define _opGetState "State Request"


/* # 52 P/N Reading */

#define opGetPN		52
#define _opGetPN "P/N Reading"

#define	aChar6	0
#define aChar5  1
#define aChar4  2
#define aChar3  3
#define aChar2  4
#define aChar1  5


/* # 58 Version Reading */

#define opGetVer	58
#define _opGetVer "Version Reading"

#define aPar1	2
#define aPar1i	"Aurora 2 kW indoor"
#define aPar1o	"Aurora 2 kW outdoor"
#define	aPar1I	"Aurora 3.6 kW indoor"
#define aPar1O	"Aurora 3.0-3.6 kW outdoor"
#define aPar15	"Aurora 5.0 kW outdoor"
#define aPar16	"Aurora 6 kW outdoor"
#define aPar1P	"3-phase interface (3G74)"
#define aPar1C	"Aurora 50kW module"
#define aPar14	"Aurora 4.2kW new"
#define aPar13	"Aurora 3.6kW new"
#define aPar12	"Aurora 3.3kW new"
#define aPar11	"Aurora 3.0kW new"
#define aPar1D	"Aurora 12.0kW "
#define aPar1X	"Aurora 10.0kW "

#define aPar2   3
#define aPar2A	"UL1741"
#define aPar2E	"VDE0126"
#define aPar2S	"DR 1663/2000"
#define aPar2I	"ENEL DK 5950"
#define aPar2U	"UK G83"
#define aPar2K	"AS 4777"
#define aPar2F	"VDE French Model"

#define aPar3   4
#define aPar3T	"Transformer Version"
#define aPar3N	"Transformerless Version"

#define aPar4   5
#define aPar4W	"Wind Version"
#define aPar4N	"Photovoltaic Version"


/* # 59 Measure request to the DSP - Type of Measure */

#define	opGetDSP	59
#define _opGetDSP "Measure request to the DSP"

#define	ToM1	1		/* Grid Voltage (Global) */
#define ToM2	2		/* Grid Currrent (Global) */
#define ToM3	3		/* Grid Power (Global) */
#define ToM4	4		/* Frequency */
#define ToM5	5		/* VBulk was Ileak (Dc/Dc) reading */
#define ToM6	6		/* Ileak (Dc/Dc) was Ileak (Inverter) Reading*/
#define ToM7	7		/* Ileak (Inverter) */
#define ToM8	8		/* Pin 1 (Global) */
#define ToM9	9		/* Pin 2 */


#define ToM21	21		/* Inverter Temperature */
#define ToM22	22		/* Booster Temperatuer */
#define ToM23	23		/* Input 1 Voltage */
#define ToM25	25		/* Input 1 Current (Global) */
#define ToM26	26		/* Input 2 Voltage */
#define ToM27	27		/* Input 2 Current */
#define ToM28	28		/* Grid Voltage (Dc/Dc) */
#define ToM29	29		/* Grid Frequency (Dc/Dc) */
#define ToM30	30		/* Isolation Resistance (Riso) */
#define ToM31	31		/* Vbulk (Dc/Dc) */
#define ToM32	32		/* Average Grid Voltage (VgridAvg) */
#define ToM33	33		/* Vbulk Mid */
#define ToM34	34		/* Power Peak */
#define ToM35	35		/* Power Peak Today */
#define ToM36	36		/* Grid Voltage neutral */
#define ToM37	37		/* Wind Generator Frequency */
#define ToM38	38		/* Grid Voltage neutral-phase */
#define ToM39	39		/* Grid Current phase r */
#define ToM40	40		/* Grid Current phase s */
#define ToM41	41		/* Grid Current phase t */
#define ToM42	42		/* Frequency phase r */
#define ToM43	43		/* Frequency phase s */
#define ToM44	44		/* Frequency phase t */
#define ToM45	45		/* Vbulk + */
#define ToM46	46		/* Vbulk - */
#define ToM47	47		/* Supervisor Temperature */
#define ToM48	48		/* Alim Temperature */
#define ToM49	49		/* Heak Sink Temperature */
#define ToM50	50		/* Temperature 1 */
#define ToM51	51		/* Temperature 2 */
#define ToM52	52		/* Temperature 3 */
#define ToM53	53		/* Fan 1 Speed */
#define ToM54	54		/* Fan 2 Speed */
#define ToM55	55		/* Fan 3 Speed */
#define ToM56	56		/* Fan 4 Speed */
#define ToM57	57		/* Fan 5 Speed */
#define ToM58	58		/* Power Saturation limit (Der.) */
#define ToM59	59		/* Riferimento Anello Bulk */
#define ToM60	60		/* Vpanel micro */
#define ToM61	61		/* Grid Voltage phase r */
#define ToM62	62		/* Grid Voltage phase s */
#define ToM63	63		/* Grid Voltage phase t */

#define _ToM1	"Grid Voltage Reading "		/* Global */
#define _ToM2	"Grid Current Reading "		/* Global */
#define _ToM3	"Grid Power Reading "		/* Global */
#define _ToM3C	"Grid Power Calculated"
#define _ToM4	"Frequency Reading"
#define _ToM5	"Vbulk"				/* was"Ileak (Dc/Dc) Reading" */
#define _ToM6	"Ileak (Dc/Dc) Reading"		/* was "Ileak (Inverter) Reading" */
#define _ToM7	"Ileak (Inverter) Reading"
#define _ToM8	"Pin 1 "			/* Global */
#define _ToM9	"Pin 2"

#define _ToM21	"Inverter Temperature"
#define _ToM22	"Booster Temperature"		/* was Environment Temperature */
#define _ToM23	"Input 1 Voltage"		/* Global was "West String Voltage" */
#define _ToM25	"Input 1 Current"		/* was "West String Current" */
#define _ToM26	"Input 2 Voltage"		/* was "East String Voltage" */
#define _ToM27	"Input 2 Current"		/* was "East String Current" */
#define _ToM28	"Grid Voltage (Dc/Dc)"
#define _ToM29	"Grid Frequency (Dc/Dc)"
#define _ToM30	"Isolation Resistance (Riso)"
#define _ToM31	"Vbulk (Dc/Dc)"
#define _ToM32	"Average Grid Voltage (VgridAvg)"
#define _ToM33	"Vbulk Mid"
#define _ToM34	"Power Peak"
#define _ToM35	"Power Peak Today"
#define _ToM36	"Grid Voltage neutral"
#define _ToM37	"Wind Generator Frequency"
#define _ToM38	"Grid Voltage neutral-phase"
#define _ToM39	"Grid Current phase r"
#define _ToM40	"Grid Current phase s"
#define _ToM41	"Grid Current phase t"
#define _ToM42	"Frequency phase r"
#define _ToM43	"Frequency phase s"
#define _ToM44	"Frequency phase t"
#define _ToM45	"Vbulk +"
#define _ToM46	"Vbulk -"
#define _ToM47	"Supervisor Temperature"
#define _ToM48	"Alim Temperature"
#define _ToM49	"Heak Sink Temperature"
#define _ToM50	"Temperature 1"
#define _ToM51	"Temperature 2"
#define _ToM52	"Temperature 3"
#define _ToM53	"Fan 1 Speed"
#define _ToM54	"Fan 2 Speed"
#define _ToM55	"Fan 3 Speed"
#define _ToM56	"Fan 4 Speed"
#define _ToM57	"Fan 5 Speed"
#define _ToM58	"Power Saturation limit (Der.)"
#define _ToM59	"Reference Ring Bulk"
#define _ToM60	"Vpanel micro"
#define _ToM61	"Grid Voltage phase r"
#define _ToM62	"Grid Voltage phase s"
#define _ToM63	"Grid Voltage phase t"

#define _Str1P	"Input 1 Power"			/* was "West String Power" */
#define _Str2P  "Input 2 Power"			/* was "East String Power" */

#define _DcAcEff	"DC/AC Coversion Efficiency"


/* # 63 Serial Number */

#define	opGetSN		63
#define _opGetSN "Serial Number"


/* # 65 Manufacturing Week and Year */

#define opGetMfg	65
#define _opGetMfg "Manufacturing Week and Year"

#define	aWeekH	2
#define aWeekL	3
#define aYearH	4
#define aYearL	5


/* # 70 Get Time/Date */

#define opGetTime	70
#define _opGetTime "Get Time/Date"


/* # 71 Set Time/Date */

#define opSetTime	71
#define _opSetTime "Set Time/Date"


/* # 72 Firmware Release */

#define opGetVerFW	72
#define _opGetVerFW "Firmware Release"

#define aRel3	2
#define aRel2   3
#define aRel1   4
#define aRel0   5


/* # 76 Energy cumulated in the last 10 seconds */

#define	opGetEnergy10Sec	76
#define _opGetEnergy10Sec "Energy cumulated in the last 10 seconds"

#define	aEnergyH	2
#define	aEnergyL	3


/* # 77 System Configuration */

#define opGetConfig	77
#define _opGetConfig "System Configuration"

#define	aConfCode	2

#define	ConfCode0	0
#define ConfCode1	1
#define ConfCode2	2

#define _ConfCode0	"System operating with both strings."
#define	_ConfCode1	"String 1 connected, String 2 disconnected."
#define	_ConfCode2	"String 2 connected, String 1 disconnected."


/* # 78 Cumulated Energy */

#define	opGetCE		78
#define _opGetCE "Cumulated Energy"

#define CEpar0	0		/* Daily Energy */
#define CEpar1  1		/* Weekly Energy */
#define CEpar2  2		/* Energy of last 7 days */
#define CEpar3  3		/* Monthly Energy */
#define CEpar4  4		/* Yearly Energy */
#define CEpar5  5		/* Total Energy (total lifetime) */
#define CEpar6  6		/* Partial Energy (cumulated since reset) */

#define _CEpar0  "Daily Energy"
#define _CEpar1  "Weekly Energy"
#define _CEpar2  "Energy last 7 days"
#define _CEpar3  "Monthly Energy"
#define _CEpar4  "Yearly Energy"
#define _CEpar5  "Total Energy"
#define _CEpar6  "Partial Energy"

/* # 80 Time Counter */

#define	opGetCounters	80
#define _opGetCounters "Time Counter"

#define	cTotalRun	0
#define cPartialRun	1
#define cTotalGrid	2
#define cResetPartial	3

#define _cTotalRun	"Total Running Time (Lifetime)"
#define _cPartialRun	"Partial Running Time (since reset)"
#define _cTotalGrid	"Total Time With Grid Connection"
#define _cResetPartial	"Reset of Partial (Time & Energy)"

/* # 86 Last four alarms */

#define opGetLastAlarms	86
#define _opGetLastAlarms "Last four alarms"

/* return codes same as alarms from # 50 State request */


